package com.mydemo.controller;

import jakarta.annotation.Resource;
import org.springframework.ai.chat.model.ChatModel;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import reactor.core.publisher.Flux;

@RestController
public class HelloWordController {

    @Resource
    private ChatModel chatModel;

    @GetMapping("/hello")
    public String hello(@RequestParam(name="msg",defaultValue = "祖国万岁" )String msg){

        return chatModel.call(msg);
    }


    @GetMapping("/hello2")
    public Flux<String> hello2(@RequestParam(name="msg",defaultValue = "祖国万岁" )String msg){
        return chatModel.stream(msg);
    }

}
